package dict.agency;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import utils.MailUtil;

public class WonDict {

	public static Map<String, String> STATE = new HashMap<String, String>();
	public static Map<String, String> RISK = new HashMap<String, String>();
	public static Map<String, Long> ALERT = new HashMap<String, Long>();
	public static Map<String, Long> HIDE = new HashMap<String, Long>();

	static {

		STATE.put("0000", "Congratulations ,transaction successful");
		STATE.put("01", "Check issuer");// 查發卡行
		STATE.put("02", "Check issuer");// 查發卡行
		STATE.put("03", "Invalid merchant");// 無效商戶
		STATE.put("04", "Confiscate the card");// 沒收卡
		STATE.put("05", "Do not honor");// 联系不到发卡行 本次交易失败
		STATE.put("06", "Merchant configuration exception");// 联系不到发卡行 本次交易失败
		STATE.put("07", "Confiscate the card under special conditions");// 特殊條件下沒收卡
		STATE.put("12", "Invalid transaction");// 無效交易
		STATE.put("13", "Invalid amount");// 無效金額
		STATE.put("14", "Invalid card number");// 無效卡號
		STATE.put("15", "Invalid card issuers");// 本次交易没有查询得到发卡行
		STATE.put("19", "Re-enter the transaction");// 重新輸入交易
		STATE.put("25", "Transaction not exist");// 過期的卡
		STATE.put("30", "format error");// 格式錯誤
		STATE.put("31", "Unknown");// 格式錯誤
		STATE.put("33", "Expired card");// 過期的卡
		STATE.put("34", "Cheating suspected");// 有作弊嫌疑
		STATE.put("35", "Merchants need to contact closed security line");// 商戶需與收單行保安部門聯系
		STATE.put("36", "Restricted card");// 交易信用卡受到发卡行限制，不允许做交易
		STATE.put("37", "Merchants call to receive special security services");// 商戶呼收單行保安部門
		STATE.put("38", "Excess Inkyo specific PIN attempts import");// 超過允許的PIN試輸入
		STATE.put("39", "Without the credit card account");// 無此信用卡賬戶
		STATE.put("41", "Reported for loss card");// 信用卡已被挂失
		STATE.put("43", "Stolen card");// 被盗窃的信用卡
		STATE.put("51", "Without enough deposit");// 無足够的存款
		STATE.put("54", "Expired card");// 過期的卡
		STATE.put("55", "Excess Inkyo specific PIN attempts import");// 不正確的PIN
		STATE.put("57", "Do not allow cardholders to deal");// 发卡行不允许持卡人进行交易
		STATE.put("58", "Do not allow the terminal for trading");// 不允許終端進行的交易
		STATE.put("59", "Cheating suspected");// 有作弊嫌疑
		STATE.put("60", "Merchants to contact security");// 商戶與保安部聯系
		STATE.put("61", "Beyond the amount limit");// 超出取款金額限制
		STATE.put("62", "Restricted card");// 信用卡受到发卡行限制不允许本次交易
		STATE.put("63", "Violation safety hermetically provisions");// 違反安全保密規定
		STATE.put("65", "Card issuers bank refuse");// 違反安全保密規定
		STATE.put("66", "Merchants call to receive the security line");// 商戶呼收單行保安部
		STATE.put("67", "Unknown");// 发卡行不支持本次交易
		STATE.put("69", "Trancation Failed");// 商戶呼收單行保安部
		STATE.put("70", "Undefine Error,Please contact the issuing bank");// 商戶呼收單行保安部
		STATE.put("75", "Mascotas para introducir el número PIN invadido");// 允許的輸入PIN次數超限
		STATE.put("76", "Please contact the issuing bank");// 請聯絡發卡銀行
		STATE.put("77", "Amount of money mistake");// 金額錯誤
		STATE.put("79", "Unknown");// 发卡行不支持本次交易
		STATE.put("89", "Terminal code wrong");// 終端機代號錯
		STATE.put("91", "Issuer or switching center can not operate");// 發卡行或交換中心不能操作
		STATE.put("92", "Financial institution or intermediary network facilities can not be found or could not be reached");// 金融機構或中間網絡設施找不到或
		STATE.put("93", "Trading is illegal, you can't accomplish");// 交易違法，不能完成
		STATE.put("94", "Repeat trade");// 重覆交易
		STATE.put("95", "Regulation refrain system complex");// 調節控制錯
		STATE.put("96", "System failure");// 系統失效
		STATE.put("98", "Exchange centre not get card issuers response");// 交換中心收不到發卡行應答
		STATE.put("A9", "Local Card");// 发卡行不支持本次交易
		STATE.put("ER", "Unknown");// 发卡行不支持本次交易
		STATE.put("H1", "Unknown");// 发卡行不支持本次交易
		STATE.put("H2", "Unknown");// 发卡行不支持本次交易
		STATE.put("H3", "Unknown");// 发卡行不支持本次交易
		STATE.put("H4", "Time Out");// 发卡行不支持本次交易
		STATE.put("N7", "Unknown");// 发卡行不支持本次交易
		STATE.put("N0", "Unknown");// 发卡行不支持本次交易
		STATE.put("Q2", "Unknown");// 发卡行不支持本次交易
		STATE.put("R3", "Unknown");// 发卡行不支持本次交易
		STATE.put("SK", "Unknown");// 发卡行不支持本次交易
		STATE.put("Z8", "Unknown");// 发卡行不支持本次交易
		STATE.put("H7", "Transaction fail");// 发卡行不支持本次交易
		STATE.put("H5", "Bank System Failure");// 发卡行不支持本次交易
		STATE.put("JR", "Transaction Pending");// 发卡行不支持本次交易
		STATE.put("TM", "Unknown");// 发卡行不支持本次交易
		STATE.put("XX", "Can not support transaction");// 发卡行不支持本次交易
		STATE.put("YX", "Card Bin not allow DCC transaction");// 卡本不允许DCC事务
		STATE.put("YY", "Card Bin allow DCC transaction");// 卡本允许DCC事务
		STATE.put("YZ", "YZ dual-currency card to refusal of payment");// YZ
		STATE.put("N7", "CVV verify error,the transaction failed");// CVV输入不正确，本次交易失败
		STATE.put("KO", "Site Forbidden");// CVV输入不正确，本次交易失败
		STATE.put("E3", "Pending");// CVV输入不正确，本次交易失败
		STATE.put("TM", "Unknown");// CVV输入不正确，本次交易失败
		STATE.put("100", "Time Out");// CVV输入不正确，本次交易失败
		STATE.put("101", "High Risk");// CVV输入不正确，本次交易失败
		STATE.put("103", "Repeated");// CVV输入不正确，本次交易失败
		STATE.put("104", "Format Error");// CVV输入不正确，本次交易失败
		STATE.put("105", "Off Limit");// CVV输入不正确，本次交易失败
		STATE.put("106", "Version Error");// CVV输入不正确，本次交易失败
		STATE.put("107", "Forbidden Country");// CVV输入不正确，本次交易失败
		STATE.put("TU0001", "Website Forbidden");// CVV输入不正确，本次交易失败
		STATE.put("0001", "Sample test error"); // 测试错误范例
		STATE.put("0024", "Merchant number or terminal number is not correct"); // 商户号或终端号不正确
		STATE.put("0025", "Hashcode been tampered with!"); // Hashcode被篡改!
		STATE.put("0026", "Risk control rule ID: xx argument exception list"); // 风控规则ID：xx
		STATE.put("1002", "CVV is error!	");// CVV错误
		STATE.put("1003", "CVV can not be null!"); // CVV不能为空
		STATE.put("1004", "Expiration year is error! infoat:yyyy"); // 到期年份是错误！
		STATE.put("1005", "Expiration year is error! infoat:MM"); // 到期年份是错误！
		STATE.put("1006", "AmountLoc can not be null!	");// 金额不能为空
		STATE.put("1007", "grAddress is error!"); // 收货地址错误
		STATE.put("1008", "grCity is error!"); // 收货市错误
		STATE.put("1009", "grCountry is error!"); // 收货国家错误
		STATE.put("1010", "CardAddress is error!"); // 持卡人地址错误
		STATE.put("1011", "CardCity is error!	");// 持卡人时错误
		STATE.put("1012", "billState is error!"); // 持卡人州错误
		STATE.put("1013", "CardCountry is error!"); // 持卡人国家错误
		STATE.put("1014", "Email errors!	");// 邮箱错误
		STATE.put("1015", "Merchant order number can not be empty"); // 商户订单号不能为空
		STATE.put("1016", "Amount must be greater than 0.01!	");// 交易金额必须大于0.01
		STATE.put("1019", "Merchant number can not be empty"); // 商户号不能为空
		STATE.put("1020", "Terminal number can not be empty"); // 终端号不能为空
		STATE.put("1029", "Submit information can not be empty	");// 提交信息不能为空
		STATE.put("1030", "Client IP is null!	");// 客户端IP为空！
		STATE.put("1101", "Merchant channel number does not exist or is not bound Cards"); // 商户号不存在或者商户通道卡种未绑定！
		STATE.put("1102", "Merchant number is not active"); // 商户号未激活
		STATE.put("1103", "Merchant corresponding channel is not opened"); // 商户未开通对应的通道
		STATE.put("1104", "Merchant terminal number is not open"); // 商户终端号未开通
		STATE.put("1105", "Channel not open	");// 通道未开通
		STATE.put("1106", "Merchants pay site is not open"); // 商户支付网址未开通
		STATE.put("1107", "Terminal number limit does not exist"); // 终端号限额不存在
		STATE.put("1108", "Do not set the single payment limit"); // 没有设置单笔支付限额
		STATE.put("1109", "No set day limit"); // 没有设置日限额
		STATE.put("1110", "Month limit is not set"); // 没有设置月限额
		STATE.put("1111", "Excess single payment"); // 单笔支付超额
		STATE.put("1112", "Excess pay day"); // 当天支付超额
		STATE.put("1113", "Month over pay"); // 当月支付超额
		STATE.put("1114", "This channel is not set rates"); // 该通道没有设置费率
		STATE.put("1115", "This channel is not set business rates"); // 该通道没有设置商户费率
		STATE.put("1118", "Authorization number wrong."); // 授权号错误。
		STATE.put("1119", "Terminal number error	");// 终端号错误
		STATE.put("1120", "Currency Trading Error"); // 交易币种错误
		STATE.put("1121", "Not set the exchange rate"); // 未设置汇率
		STATE.put("1122", "Incoming transactions can not be empty	");// 传入交易数据不能为空
		STATE.put("1123", "Get Rates failure, determine whether the terminal has a custom or default currency exchange"); // 获取汇率失败，请确定该终端是否有定制汇率或默认汇率
		STATE.put("1124", "Get exchange rates can not be empty"); // 获取汇率信息不能为空
		STATE.put("1125", "Merchant number or terminal number can not be empty"); // 商户号或终端号不能为空
		STATE.put("1126", "Exchange Rates Source currency can not be empty"); // 汇率查询源币种不能为空
		STATE.put("1127", "Currency Exchange Rates goal can not be empty"); // 汇率查询目标币种不能为空
		STATE.put("1128", "Exchange Rates type can not be empty"); // 汇率查询类型不能为空
		STATE.put("1129", "DCC exchange rate channel inquiry failed to find EDC account is empty"); // DCC通道查询汇率失败，查找EDC账号为空
		STATE.put("1130", "DCC exchange rate channel inquiry failed to find EDC or bank account acquisition channel configuration is configured to empty"); // DCC通道查询汇率失败，查找EDC账号获取通道配置或银行配置为空
		STATE.put("1131", "Failure to obtain bank payments returned results"); // 获取银行支付结果返回失败
		STATE.put("1132", "Merchant payment limit URL"); // 商户支付网址限制
		STATE.put("1134", "Merchant number can not be empty"); // 商户号不能为空
		STATE.put("1135", "Get source URL fails"); // 获取来源网址失败
		STATE.put("1136", "Get settlement rate can not be empty	");// 获取结算汇率不能为空
		STATE.put("1137", "Merchant payment terminal is not open currency"); // 商户终端未开通支付币种
		STATE.put("1138", "Parameter goodsString is error"); // 货物字符串错误
		STATE.put("1139", "Parameter apiType is error"); // 支付接口类型错误
		STATE.put("1140", "Decrypt data error"); // 非对称解密错误
		STATE.put("1141", "Prohibit access"); // 参数伪造，禁止访问
		STATE.put("1200", "Merchants pay channel does not exist"); // 商户支付通道不存在
		STATE.put("1201", "Bank does not open"); // 银行未开通
		STATE.put("1202", "Channel not open	");// 通道未开通
		STATE.put("1203", "Bank error configuration information"); // 银行配置信息错误
		STATE.put("1204", "Channel configuration error	");// 通道配置信息错误
		STATE.put("1206", "Card type does not exist"); // 卡类型不存在
		STATE.put("1406", "Invalid wind control rules	");// 风控无效规则
		STATE.put("1407", "Wind control parameter is empty"); // 风控参数为空
		STATE.put("1408", "Wind control matching parameter is null"); // 风控匹配参数为空
		STATE.put("1500", "high risk refuse"); // 高风险的拒绝！
		STATE.put("1501", "high risk pending"); // 高风险待处理
		STATE.put("2002", "Submit Bank Failure"); // 提交银行失败
		STATE.put("2003", "Transaction information can not be empty"); // 交易信息不能为空
		STATE.put("2004", "Vpn generated record failed."); // 生成vpn记录失败。
		STATE.put("3084", "	Insufficient funds in the account."); // 生成vpn记录失败。
		STATE.put("3100", "Do not honor");// CVV输入不正确，本次交易失败

		ALERT.put("555", 0L);
		ALERT.put("1202", 0L);
		ALERT.put("2031", 0L);

		// HIDE.put("9905", 0);
	}

	public static synchronized String message(String code) {

		if (STATE.containsKey(code)) {
			return STATE.get(code).toString();
		}
		return "unknown exception";
	}

	public static synchronized void warning(String code, int limit) {
		String name = "WON";
		String time = new SimpleDateFormat("HH:mm:ss").format(new Date());
		if (ALERT.containsKey(code)) {
			ALERT.put(code, ALERT.get(code) + 1);
			if (new Integer(ALERT.get(code).toString()) > limit) {
				ALERT.put(code, 0L);
				MailUtil.sendEmail(MailUtil.tos, "警告", "[" + time + "]" + name + "返回码[" + code + "]超过[" + limit + "]次");
			}
		}
	}

	public static void main(String[] args) {
	}

}
